{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a3dc9534",
   "metadata": {},
   "source": [
    "-------\n",
    "* 2022/10/10 / week07\n",
    "* Python学习记录\n",
    "-------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c10bb8d1",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "\n",
    "* 1. 有序的数据结构——字符串(str)\n",
    "\n",
    "* 2. 有序的数据结构——列表(list)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e01f888",
   "metadata": {},
   "source": [
    "## 1. 字符串（string）\n",
    "\n",
    "> 1. 关于字符串的基本内容\n",
    "> 2. 关于字符串的方法及函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "44a588d1",
   "metadata": {},
   "source": [
    "### 1.1 [关于字符串的基本内容](https://docs.python.org/3/tutorial/introduction.html#strings)\n",
    "\n",
    "* Single quotes: 'allows embedded \"double\" quotes'\n",
    "\n",
    "* Double quotes: \"allows embedded 'single' quotes\"\n",
    "\n",
    "* Triple quoted: '''Three single quotes''', \"\"\"Three double quotes\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0021657d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'spam eggs'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'spam eggs' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1a88392b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type('spam eggs' ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f4f91cf1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(\"spam eggs\" ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6c276493",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-5-f70cf6904edb>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-5-f70cf6904edb>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    'doesn't'\u001b[0m\n\u001b[1;37m           ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "'doesn't'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "926847ab",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 以上解决方案\n",
    "\"doesn't\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "20e5d435",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'doesn\\'t'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c187d30e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 三引号：保留字符串信息的 格式信息,保留完整的数据信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "23a231fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''doesn't'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "d8c33e2e",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "EOL while scanning string literal (<ipython-input-11-b52479b251c1>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-11-b52479b251c1>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    \"Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\u001b[0m\n\u001b[1;37m                                                                                                                      ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m EOL while scanning string literal\n"
     ]
    }
   ],
   "source": [
    "\"Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
    "\n",
    "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d088c40c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
      "\n",
      "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is\n"
     ]
    }
   ],
   "source": [
    "print('''Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
    "\n",
    "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "876af836",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Usage: thingy [OPTIONS]\n",
      "     -h                        Display this usage message\n",
      "     -H hostname               Hostname to connect to\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\"\"\"\\\n",
    "Usage: thingy [OPTIONS]\n",
    "     -h                        Display this usage message\n",
    "     -H hostname               Hostname to connect to\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7e1d4cd5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<script type=\"importmap\" nonce=\"\"> { \"imports\": {\"rms-answers-HomepageVNext-PeregrineWidgets\":\"https://assets.msn.com/bundles/v1/bingHomepage/latest/widget-initializer.js\"} } </script>\n"
     ]
    }
   ],
   "source": [
    "print('''<script type=\"importmap\" nonce=\"\"> { \"imports\": {\"rms-answers-HomepageVNext-PeregrineWidgets\":\"https://assets.msn.com/bundles/v1/bingHomepage/latest/widget-initializer.js\"} } </script>''')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e63dc15e",
   "metadata": {},
   "source": [
    "### 1.2 [关于字符串的方法及函数](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)\n",
    "\n",
    "> 1. 字符串是可以拼接的（字符串的运算）,用 + 进行字符串之间的拼接\n",
    "> 2. 字符串是有顺序的,从第一个字符开始，从0依次往后；有长度，可以用len()检查字符串的长度\n",
    "> 3. 字符串的取值：\n",
    ">> 1. 取单个值 :从左往右（正数，第一个值是0），从右往左（负数，第一个值是-1）\n",
    ">> 2. 取多个值 :切片的方法，两个值作为 取值的区间\n",
    "> 4. 字符串的方法及函数\n",
    ">> 1. in 查询成员是否存在\n",
    ">> 2. str.count() 查询数量\n",
    ">> 3. str.isdigit() 判断字符串是否是 数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "11283774",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_name = [\"小明\",\"小红\",\"张杰\",\"李华\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "ae180e6e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院团委欢迎小明\n",
      "广州南方学院团委欢迎小红\n",
      "广州南方学院团委欢迎张杰\n",
      "广州南方学院团委欢迎李华\n"
     ]
    }
   ],
   "source": [
    "for i in new_name:\n",
    "    print(\"广州南方学院团委欢迎\"+i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6a120628",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"广州南方学院团委欢迎\"+\"小明\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "37055088",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text = '广州南方学院团委欢迎小明'\n",
    "text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "6fda0b30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "163c8e00",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'州'"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "793bdb2f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'南'"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "3ff15d0d",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-30-a4cec855b1ea>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtext\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m12\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "text[12]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "36d6a5ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "7c7db4a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[6]+text[7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "1dfa2d19",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用 切片 的方法进行多个值取值\n",
    "text[6:8]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4933d749",
   "metadata": {},
   "source": [
    "* in 查询成员"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "cd72dafb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'广州' in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "d210a82d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'北京' in text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dd3196ae",
   "metadata": {},
   "source": [
    "* str.count() 查询数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "a34a5c84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.count('广州')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f9a59e9",
   "metadata": {},
   "source": [
    "* str.isdigit() 判断字符串是否是 数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "6cf46ef6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19 <class 'int'>\n",
      "19 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "age_li = 19\n",
    "age_wang = '19'\n",
    "print(age_li,type(age_li))\n",
    "print(age_wang,type(age_wang))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "25e9bb56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_wang.isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "33b3944c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.isdigit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8b0c3b7",
   "metadata": {},
   "source": [
    "## 2. 有序的数据结构——列表(list)\n",
    "\n",
    "* Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. Lists might contain items of different types, but usually the items all have the same type.\n",
    "\n",
    "> 1. 列表的基本运算法则（参考：有序的数据结构的运算法则列表）\n",
    "> 2. 列表的一般方法（要求：全部掌握，并且做总结在课后笔记中）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "423e21b5",
   "metadata": {},
   "source": [
    "### 2.1 列表的基本运算法则"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "ff206ad5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 思考：假设，有这样一个场景，我要录入/存放一个班的同学的信息（名单信息），用字符串存放是否可行？如何取值呢？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "c4aca529",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串存放\n",
    "网二_name = \"李华，小明，李晓华，小红\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "da01b24a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "727e9eb8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串取值,比较麻烦\n",
    "网二_name[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "db72eddd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'小明'"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "7c6c39cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李晓华'"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[6:9]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a37ed2c4",
   "metadata": {},
   "source": [
    "* 对比字符串和列表\n",
    "> 1. 字符串是按照字符进行数据取值\n",
    "> 2. 列表是按照元素进行数据取值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "8923b26e",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_name_list = [\"李华\",\"小明\",\"李晓华\",\"小红\"]  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "6559a94e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "34591f57",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "84af4948",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李晓华', '小红']"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[-2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "a1e830db",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_age_list = [19,18,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "867caad4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "13628e84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19, 18, 19, 20]"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list[:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "c1c7a274",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list.count(19)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5312eea0",
   "metadata": {},
   "source": [
    "### 2.2 [列表的方法](https://docs.python.org/3/library/stdtypes.html#lists)\n",
    "\n",
    "> 1. 增加\n",
    "> 2. 删除\n",
    "> 3. 修改\n",
    "> 4. 查询  in，count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "874291ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"Mike\",\"Marry\",\"Jan\",\"Jack\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f05381b7",
   "metadata": {},
   "source": [
    "* 学习方法 \n",
    "> 1. listname.Tab键 查看所有方法名称\n",
    "> 2. help(listname.function) 查看其中一个方法的具体操作内容\n",
    "\n",
    "> 课后练习（做一个表格，总结列表的方法）：\n",
    "\n",
    "\n",
    "| 列表方法      | Description | example      |备注|\n",
    "| ----------- | ----------- |----------- |----------- |\n",
    "| append()      |  增加元素，增加在列表的末尾      | names.append(\"zhichao\")，  ['Mike', 'Marry', 'Jan', 'Jack', 'zhichao'] |   |\n",
    "| Paragraph   | Text        |   |   |\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "b96c9af1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "f9b4e773",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "3324a231",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Marry', 'Jan', 'Jack', 'zhichao']"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "aa869d29",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "7d6416fe",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(1,\"Alex\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "90225b2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Alex', 'Marry', 'Jan', 'Jack', 'zhichao']"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7d78e7a6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
